package file;

import java.io.File;
import java.io.FileFilter;

public class ListFilesDemo2 {
    public static void main(String[] args) {
        File dir = new File("./src/file");
        if (dir.isDirectory()) {

            FileFilter filter = new FileFilter() {
                public boolean accept(File file) {
                    return file.getName().contains("F");
                }
            };
            File[] subs = dir.listFiles(filter);
            System.out.println("共：" + subs.length + "个子项");
            for (int i = 0; i < subs.length; i++) {
                File sub = subs[i];
                System.out.println(sub.getName());
            }
        }
    }
}
